package test.com.sms.selenium.singlepoint.util;


import org.openqa.selenium.By;
import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpActivityBoardContractDetailsPageUtil extends SeleniumPageUtil {
	/*tab*/
	public final static By ABCD_LINK_GENERAL = By.id("btnTab1");
	public final static By ABCD_LINK_DISCOUNTS = By.id("btnTab2");
	public final static By ABCD_LINK_CONTRACT_ITEMS = By.id("btnTab3");
	public final static By ABCD_LINK_CART = By.id("btnTab4");
	public final static By ABCD_LINK_IN_PROGRESS = By.id("btnTab5");
	public final static By ABCD_LINK_NEED_APPROVAL = By.id("btnTab6");
	public final static By ABCD_LINK_CHANGE_HISTORY = By.id("btnTab7");
	public final static By ABCD_LINK_INVOICES = By.id("btnTab8");
	public final static By ABCD_LINK_CONTACTS = By.id("btnTab9");
	public final static By ABCD_LINK_NOTES = By.id("btnTab11");
	
	/* filter details*/
	public final static By ABCD_INPUT_TEXT = By.id("txtFilters");
	public final static By ABCD_BUTTONT_OK = By.id("btnOK");
	public final static By ABCD_BUTTONT_CANCEL = By.id("btnCancel");
	
	public final static By ABCD_LINK_SELECT_ALL = By.xpath("//*[@id='ContractLineListAjax_ajaxTblHdr']/tbody/tr[1]/td[2]/a[2]");
	public final static By ABCD_CHECKBOX_LIST = By.xpath("//*[@id='ContractLineListAjax_ajaxTbl']/tbody//tr/td[2]/input[@type='checkbox']");
	public final static By ABCD_CHECKBOX_NOICON_LIST = By.xpath("//*[@id='ContractLineListAjax_ajaxTbl']/tbody//tr/td[2][not(../td[3]/a)]/input[@type='checkbox']");
	
	// actions list
	public final static By ABCD_TD_LIST_ADDRESS = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[19]/td[1]");
	public final static By ABCD_TD_LIST_SLA = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[15]/td");
	public final static By ABCD_TD_LIST_ADD_NEW_ASSET = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[3]/td");
	public final static By ABCD_TD_LIST_ADD_SMS_COVERAGE_TO_ASSET = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[5]/td");
	public final static By ABCD_TD_LIST_END_SMS_COVERAGE = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[9]/td");
	public final static By ABCD_TD_LIST_VIEW_DISCREPANCIES = By.xpath("//*[@id='ContractLineListAjax_lblChgReqAction']/table/tbody/tr[6]/td");
	
	/* contract items tab*/
	public final static By ABCD_SPAN_ACTIONS = By.id("ContractLineListAjax_lblActions");
	public final static By ABCD_TABLE_RESULTS = By.id("ContractLineListAjax_ajaxTbl");
	public final static By ABCD_IMG_LINE_6_FILTER = By.xpath("//*[@id='ContractLineListAjax_ajaxTblHdr']/tbody/tr[1]/td[5]/div/img[1]");
	public final static By ABCD_IMG_FILTER_ASIGN = By.id("imgLine");
	public final static By ABCD_LINK_LINES = By.xpath("//*[@id='ContractLineListAjax_ajaxTbl']/tbody/tr/td[5]");
	public final static By ABCD_BUTTON_END_COVERAGE_POPUP_OK = By.xpath("//*[@id='ctl44_btnOK']");
	public final static By ABCD_BUTTON_END_COVERAGE_POPUP_CANCEL = By.xpath("//*[@id='ctl44_btnCancel']");
	
	
	// the serial number of first result under contract items tab
	public final static By ABCD_TR_DUPLICATE_SERIAL_NUMBER = By.xpath("//*[@id='ContractLineListAjax_ajaxTbl']/tbody/tr[1]/td[9]/a");
	// the asset name of first result under contract items tab
	public final static By ABCD_LINK_ASSET_NAME_CONTRACT_ITEMS = By.xpath("//*[@id='ContractLineListAjax_ajaxTbl']/tbody/tr[1]/td[6]/a");
	
	/*cart tab*/
	public final static By ABCD_LINK_REFRESH_CART = By.id("ContractChgRequestsAjax_btnRefresh");
	public final static By ABCD_LINK_DELETE_CART = By.id("ContractChgRequestsAjax_btnDeleteSelected");
	public final static By ABCD_LINK_SUBMIT_TO_QUOTE_CART = By.id("ContractChgRequestsAjax_btnAddToQuote");
	public final static By ABCD_TR_RESULTS_CART = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTbl']/tbody/tr");
	public final static By ABCD_TR_RESULTS = By.id("ContractChgRequestsAjax_ajaxTbl");
	public final static By ABCD_TABLE_RESULTS_CART = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr");
	
	public final static By ABCD_INPUT_CHECK_BOX = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTbl']/tbody/tr[1]/td[2]/input");
	public final static By ABCD_B_CART_TAB_ITEMS = By.xpath("//*[@id='btnTab4']/b");

	// cart filter
	public final static By ABCD_IMG_FILTER_SELECT = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[2]/div/img[1]");
	public final static By ABCD_IMG_FILTER_ORDER = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[3]/div/img[1]");
	public final static By ABCD_IMG_FILTER_NEW_LINE = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[4]/div/img[1]");
	public final static By ABCD_IMG_FILTER_CHANGES_TYPE = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[6]/div/img[1]");
	public final static By ABCD_IMG_FILTER_STATUS = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[7]/div/img[1]");
	public final static By ABCD_IMG_FILTER_SERIAL_NUMBER = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[8]/div/img[1]");
	public final static By ABCD_IMG_FILTER_ASSET_NAME = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[9]/div/img[1]");
	public final static By ABCD_IMG_FILTER_ASSET_TYPE = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[10]/div/img[1]");
	public final static By ABCD_IMG_FILTER_MFG_NAME = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[11]/div/img[1]");
	public final static By ABCD_IMG_FILTER_MODEL_CODE = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[12]/div/img[1]");
	public final static By ABCD_IMG_FILTER_CUST_ADDRESS = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[17]/div/img[1]");
	public final static By ABCD_IMG_FILTER_REQ_ADDRESS = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[18]/div/img[1]");
	public final static By ABCD_IMG_FILTER_SLA = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[19]/div/img[1]");
	public final static By ABCD_IMG_FILTER_REQ_SLA = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[20]/div/img[1]");
	public final static By ABCD_IMG_FILTER_CREATED = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTblHdr']/tbody/tr[1]/td[23]/div/img[1]");
	
	/*in progress tab*/
	public final static By ABCD_LINK_REFRESH_IN_PROGRESS = By.id("ContractChgRequestsAjax_btnRefresh");
	public final static By ABCD_TR_RESULTS_IN_PROGRESS = By.xpath("//*[@id='ContractChgRequestsAjax_ajaxTbl']/tbody/tr");
	public final static By ABCD_B_RESULTS_SIZE_IN_PROGRESS = By.xpath("//*[@id='btnTab5']/b");
	public final static By ABCD_SPAN_RECORDS = By.id("ContractChgRequestsAjax_lblNumRecs");
	
	/** if contract items tab page upload complete, it at least 1 result*/
	public static void waitForResultsUpload(By by) {
		boolean flag = SeleniumUtil.findElements(by).size() < 1;
		long before = System.currentTimeMillis();
		while(flag){
			if((System.currentTimeMillis() - before) > 120 * 1000){
				SeleniumUtil.fail("more than 2 minutes no response!");
				return;
			}else{
				flag = SeleniumUtil.findElements(by).size() < 1;
			}
		}
		SeleniumUtil.waitForFixedMilliseconds(3000);
	}
	
	/** wait for cart tab results display*/
	public static void waitForCartResultsDisplay(){
		SeleniumUtil.waitOnElements(new By[]{
				ABCD_LINK_SUBMIT_TO_QUOTE_CART, ABCD_IMG_FILTER_SELECT, ABCD_IMG_FILTER_ORDER, ABCD_IMG_FILTER_NEW_LINE, ABCD_IMG_FILTER_CHANGES_TYPE, 
				ABCD_IMG_FILTER_STATUS, ABCD_IMG_FILTER_SERIAL_NUMBER, ABCD_IMG_FILTER_ASSET_NAME, ABCD_IMG_FILTER_ASSET_TYPE, ABCD_IMG_FILTER_MFG_NAME, 
				ABCD_IMG_FILTER_MODEL_CODE, ABCD_IMG_FILTER_CUST_ADDRESS, ABCD_IMG_FILTER_REQ_ADDRESS, ABCD_IMG_FILTER_SLA, ABCD_IMG_FILTER_REQ_SLA, 
				ABCD_IMG_FILTER_CREATED
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_LINK_SUBMIT_TO_QUOTE_CART));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_SELECT));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_ORDER));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_NEW_LINE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_CHANGES_TYPE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_STATUS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_SERIAL_NUMBER));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_ASSET_NAME));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_ASSET_TYPE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_MFG_NAME));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_MODEL_CODE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_CUST_ADDRESS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_REQ_ADDRESS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_SLA));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_REQ_SLA));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(ABCD_IMG_FILTER_CREATED));
	}
	
}
